#include <avr/io.h>

#define MOSI _BV(PB6)
#define SCK _BV(PB7)
#define CS _BV(PB4)
#define WAKE _BV(PD2)
#define INT _BV(PD3)
#define RESET _BV(PD4)

void SPI_MasterInit(void)
{
	// Set outputs
	DDRB |= MOSI | SCK | CS;
	DDRD |= WAKE | INT | RESET;

	/* Enable SPI, Master, set clock rate fck/16 */
	SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR0);
}

void SPI_MasterTransmit(char cData)
{
	/* Start transmission */
	SPDR = cData;

	/* Wait for transmission complete */
	while(!(SPSR & (1<<SPIF)))
	{
		// Do Nothing
	}
}
